package ex.inte;

import java.time.Duration;
import java.time.Period;
import java.time.temporal.TemporalAmount;
import java.util.Date;

/**
 * @author small瑞
 */
public class MyLocalDateTime {
    private final int year;
    private final int month;
    private final int day;
    private final int hour;
    private final int minute;
    private final int second;
    private final int nanos;

    private MyLocalDateTime(int year, int month, int day, int hour, int minute, int second, int nanos) {
        this.year = year;
        this.month = month;
        this.day = day;
        this.hour = hour;
        this.minute = minute;
        this.second = second;
        this.nanos = nanos;
    }
//    private MyLocalDateTime(int year, int month, int day) {
//        this.year = year;
//        this.month = month;
//        this.day = day;
//    }
//
//    private MyLocalDateTime(int year, int month, int day, int hour) {
//        this.year = year;
//        this.month = month;
//        this.day = day;
//        this.hour = hour;
//    }
//
//    private MyLocalDateTime(int year, int month, int day, int hour, int minute) {
//        this.year = year;
//        this.month = month;
//        this.day = day;
//        this.hour = hour;
//        this.minute = minute;
//    }
//
//    public  MyLocalDateTime(int year, int month, int day, int hour, int minute, int second) {
//        this.year = year;
//        this.month = month;
//        this.day = day;
//        this.hour = hour;
//        this.minute = minute;
//        this.second = second;
//    }


    @Override
    public String toString() {
        return  year
                +"-"+
                month
                +"-"+
                day
                +" "+
                hour
                +":"+
                minute
                +":"+
                second
                +" "+
                nanos;
    }
    private  MyLocalDateTime check(){
        int day   = this.day;
        int year  = this.year;
        int month = this.month;
        int hour  = this.hour;
        int minute= this.minute;
        int second= this.second;
        int nanos = this.nanos;
        if(year%4==0){
            if(nanos>=1000){
                second+=nanos/1000;
                nanos%=1000;
            }
            if(second>=60){
                minute+=second/60;
                second%=60;
            }
            if(minute>=60){
                hour+=minute/60;
                minute%=60;
            }
            if(hour>=24){
                day+=hour/24;
                hour%=24;
            }
            if(month>12){
                year+=month/12;
                month%=12;
            }
            do{
                switch (month){
                    case 1  :
                    case 3  :
                    case 5  :
                    case 7  :
                    case 8  :
                    case 10 :
                        if(day>31){
                            day-=31;
                            month++;
                        }break;
                    case 2  :
                        if(day>29){
                            day-=29;
                            month++;
                        }
                    case 4  :
                    case 6  :
                    case 9  :
                    case 11 :
                        if(day>30){
                            day-=30;
                            month++;
                        }
                    case 12 :
                        if(day>31){
                            day-=31;
                            month = 1;
                            year++;
                        }




                }
            }while(day>31);

        }
        if(year%4!=0){
            if(nanos>=1000){
                second+=nanos/1000;
                nanos%=1000;
            }
            if(second>=60){
                minute+=second/60;
                second%=60;
            }
            if(minute>=60){
                hour+=minute/60;
                minute%=60;
            }
            if(hour>=24){
                day+=hour/24;
                hour%=24;
            }
            if(month>12){
                year+=month/12;
                month%=12;
            }
            do{
                switch (month){
                    case 1  :
                    case 3  :
                    case 5  :
                    case 7  :
                    case 8  :
                    case 10 :
                        if(day>31){
                            day-=31;
                            month++;
                        }break;
                    case 2  :
                        if(day>28){
                            day-=28;
                            month++;
                        }
                    case 4  :
                    case 6  :
                    case 9  :
                    case 11 :
                        if(day>30){
                            day-=30;
                            month++;
                        }
                    case 12 :
                        if(day>31){
                            day-=31;
                            month = 1;
                            year++;
                        }




                }
            }while(day>31);
        }
        return new MyLocalDateTime(year , month , day , hour , minute , second , nanos);
    }

    public static MyLocalDateTime of(int year, int month, int day){

        return new MyLocalDateTime(year , month , day ,0,0,0,0).check();
    }
    public static MyLocalDateTime of(int year, int month, int day, int hour){
        return new MyLocalDateTime(year , month , day , hour ,0,0,0).check();
    }
    public static MyLocalDateTime of(int year, int month, int day , int hour , int minute){
        return new MyLocalDateTime(year ,month , day , hour , minute ,0,0).check();
    }
    public static MyLocalDateTime of(int year, int month, int day , int hour , int minute , int second){
        return new MyLocalDateTime(year , month , day , hour , minute , second ,0).check();
    }
    public static MyLocalDateTime of(int year, int month, int day , int hour , int minute , int second , int nanos){
        return new MyLocalDateTime(year , month , day , hour , minute , second , nanos ).check();
    }

    public MyLocalDateTime plus(TemporalAmount amount){
        if(amount instanceof Duration){
           // System.out.println("运行到了这里ss");
            return dplus((Duration) amount);
        }
        else {
            //System.out.println("运行到了这里ssddddd");
            return pplus((Period) amount);
        }


    }
    public MyLocalDateTime dplus(Duration duration){
        int day   = this.day;
        int year  = this.year;
        int month = this.month;
        int hour  = this.hour;
        int minute= this.minute;
        int second= this.second;
        int nanos = this.nanos;

        long mount = duration.getSeconds();
        //System.out.println("运行到了这里"+duration.getSeconds());
        second += mount;
        long index = mount/86400;
        do{
            if(nanos >= 1000){
                second += nanos/1000;
                nanos %= 1000;
            }
            if(second >= 60){
                minute += second/60;
                second %= 60;
            }
            if(minute >= 60){
                hour += minute/60;
                minute %=60;
            }
            if(hour >= 24){
                day++;
                hour -= 24;
                index--;
            }
        }while(index!=0);

        return of(year , month , day , hour , minute , second , nanos);
    }
    public MyLocalDateTime pplus(Period period){
        int day    = this.day;
        int year   = this.year;
        int month  = this.month;
        int hour   = this.hour;
        int minute = this.minute;
        int second = this.second;
        int nanos  = this.nanos;

        int count = period.getDays();

        day+=count;
        if(year%4==0){
            int index = count/366;
            do{
                while(day>29){
                    switch (month){
                        case 1  :
                        case 3  :
                        case 5  :
                        case 7  :
                        case 8  :
                        case 10 :
                        case 12 :
                            if(day>31){month++;day-=31;}break;
                        case 2  : if(day>29){month++;day-=29;}break;
                        case 4  :
                        case 11 :
                        case 9  :
                        case 6  :
                            if(day>30){month++;day-=30;}break;
                        default : if(year>12){year++;month-=12;index--;}
                    }
                }

            }while(index!=0);
        }
        if(year%4!=0){
            int index = count/365;
            do{
                while(day>28){
                    switch (month){
                        case 1  :
                        case 3  :
                        case 5  :
                        case 7  :
                        case 8  :
                        case 10 :
                        case 12 :
                            if(day>31){month++;day-=31;}break;
                        case 2  : if(day>28){month++;day-=28;}break;
                        case 4  :
                        case 11 :
                        case 9  :
                        case 6  :
                            if(day>30){month++;day-=30;}break;
                        default : if(year>12){year++;month-=12;index--;}
                    }
                }

            }while(index!=0);
        }



        return of(year , month , day , hour , minute , second , nanos);
    }
    public MyLocalDateTime plusYear(int year){
        int day   = this.day;
        int month = this.month;
        int hour  = this.hour;
        int minute= this.minute;
        int second= this.second;
        int nanos = this.nanos;

        year += this.year;
        return new MyLocalDateTime(year , month , day , hour , minute , second , nanos );

    }
    public MyLocalDateTime plusMonth(int month){
        int day   = this.day;
        int year = this.year;
        int hour  = this.hour;
        int minute= this.minute;
        int second= this.second;
        int nanos = this.nanos;

        month += this.month;

        while(month>12){
            year++;
            month-=12;
        }
        return new MyLocalDateTime(year , month , day , hour , minute , second , nanos );

    }
    public MyLocalDateTime plusDay(int day){
        int year   = this.year;
        int month = this.month;
        int hour  = this.hour;
        int minute= this.minute;
        int second= this.second;
        int nanos = this.nanos;

        day += this.day;
        //System.out.println("运行到了这里"+day);
        if(year%4==0){
            int index = day/366;
            do{
                //System.out.println("运行到了这里"+index);
                while(day>29){
                    //System.out.println("运行到了这里"+day);
                    switch (month){
                        case 1  :
                        case 3  :
                        case 5  :
                        case 7  :
                        case 8  :
                        case 10 :
                        case 12 :
                            if(day>31){month++;day-=31;}break;
                        case 2  : if(day>29){month++;day-=29;}break;
                        case 4  :
                        case 11 :
                        case 9  :
                        case 6  :
                            if(day>30){month++;day-=30;}break;
                        default : if(month>12){year++;month-=12;index--;}

                    }
                    //System.out.println("运行到了这里"+day);
                }

            }while(index!=0);
        }
        if(year%4!=0){
            int index = day/365;
            do{
                while(day>28){
                    switch (month){
                        case 1  :
                        case 3  :
                        case 5  :
                        case 7  :
                        case 8  :
                        case 10 :
                        case 12 :
                            if(day>31){month++;day-=31;}break;
                        case 2  : if(day>28){month++;day-=28;}break;
                        case 4  :
                        case 11 :
                        case 9  :
                        case 6  :
                            if(day>30){month++;day-=30;}break;
                        default : if(year>12){year++;month-=12;index--;}
                    }
                }

            }while(index!=0);
        }
        //System.out.println("运行到了这里"+month);
        return new MyLocalDateTime(year , month , day , hour , minute , second , nanos );
    }
    public MyLocalDateTime plusHour(int hour){
        int day    = this.day;
        int year   = this.year;
        int month  = this.month;
        int minute = this.minute;
        int second = this.second;
        int nanos  = this.nanos;
        hour = hour+ this.hour;
        int index = hour / 24;
        hour = hour%24;
        //System.out.println("运行到了这里"+hour);
        MyLocalDateTime myLocalDateTime = MyLocalDateTime.of(year , month , day , hour , minute , second , nanos );
        //System.out.println("运行到了这里"+myLocalDateTime);
        return myLocalDateTime.plusDay(index);

    }
    public MyLocalDateTime plusMinute(int minute){
        int day    = this.day;
        int year   = this.year;
        int month  = this.month;
        int hour   = this.hour;
        int second = this.second;
        int nanos  = this.nanos;

        minute +=this.minute;
        int index = minute/60;
        minute %=60;
        MyLocalDateTime myLocalDateTime = MyLocalDateTime.of(year , month , day , hour , minute , second , nanos);
        return myLocalDateTime.plusHour(index);
    }
    public MyLocalDateTime plusSecond(int second){
        int day    = this.day;
        int year   = this.year;
        int month  = this.month;
        int hour   = this.hour;
        int minute = this.minute;
        int nanos  = this.nanos;

        second +=this.second;
        int index = second/60;
        second %=60;
        MyLocalDateTime myLocalDateTime = MyLocalDateTime.of(year , month , day , hour , minute , second , nanos);
        return myLocalDateTime.plusMinute(index);

    }
    public MyLocalDateTime plusNanos(int nanos){
        int day    = this.day;
        int year   = this.year;
        int month  = this.month;
        int hour   = this.hour;
        int minute = this.minute;
        int second  = this.second;

        nanos +=this.nanos;
        int index = nanos/1000;
        nanos %=1000;
        MyLocalDateTime myLocalDateTime = MyLocalDateTime.of(year , month , day , hour , minute , second , nanos);
        return myLocalDateTime.plusSecond(index);
    }

    public MyLocalDateTime minus(TemporalAmount amount){
        if(amount instanceof Duration){
            // System.out.println("运行到了这里ss");
            return dminus((Duration) amount);
        }
        else {
            //System.out.println("运行到了这里ssddddd");
            return pminus((Period) amount);
        }
    }
    public MyLocalDateTime dminus(Duration duration){
        int day   = this.day;
        int year  = this.year;
        int month = this.month;
        int hour  = this.hour;
        int minute= this.minute;
        int second= this.second;
        int nanos = this.nanos;

        long mount = duration.getSeconds();
        //System.out.println("运行到了这里"+duration.getSeconds());
        //second += mount;
        //long index = mount/86400;
        while(mount>=3600){
            if(hour==0){
                mount-=3600;
                hour=23;
                day--;

            }
            else {
                mount-=3600;
                hour--;
            }

        }
        while(mount>=60){
            if(minute==0){
                mount-=60;
                minute = 59 ;
                if(hour==0){
                   hour=23;
                   day--;
                }
                else  {
                    hour--;
                }
            }
            else {
                mount-=60;
                minute--;
            }

        }
        while(mount!=0){
            if(second==0){
                mount--;
                second = 59;
                minute--;
            }
            else{
                mount--;
                second--;
            }
        }

        return of(year , month , day , hour , minute , second , nanos);
    }
    public MyLocalDateTime pminus(Period period){
        int day    = this.day;
        int year   = this.year;
        int month  = this.month;
        int hour   = this.hour;
        int minute = this.minute;
        int second = this.second;
        int nanos  = this.nanos;

        int count = period.getDays();
        //System.out.println("运行到了这里"+count);

        //day+=count;
        do{
            switch (month) {
                case 1:
                    if (count > day) {
                        count -= day;
                        month = 12;
                        year--;
                        day=31;
                    }
                    else {
                        day-=count;
                        count=0;
                        if(day==0){
                            day = 31 ;
                            month = 12;
                            year--;
                        }
                    }
                    break;
                case 3:
                    if (count > day) {
                        count -= day;
                        month--;
                        if(year%4==0){
                            day=29;
                        }
                        else{
                            day=28;
                        }
                    }
                    else {
                        day-=count;
                        count=0;
                        if(day==0){
                            month --;
                            if(year%4==0){
                                day=29;
                            }
                            else{
                                day=28;
                            }
                        }
                    }
                    break;
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    //System.out.println("运行到了这里"+count);
                    if (count > day) {
                       // System.out.println("运行到了这里"+day);
                        count -= day;
                       // System.out.println("运行到了这里"+count);
                        month--;
                        day=30;
                    }
                    else {
                        day-=count;
                        count=0;
                        if(day==0){
                            day = 30 ;
                            month --;
                        }
                    }
                    break;
                case 2:
                case 4:
                case 11:
                case 9:
                case 6:
                    if (count > day) {
                        count -= day;
                        month--;
                        day=31;
                    }
                    else {
                        day-=count;
                        count=0;
                        if(day==0){
                            day = 31 ;
                            month--;
                        }
                    }
                    break;
                default:System.out.println("xxx");
            }
            //System.out.println("运行到了这里"+count);
        }while(count!=0);
        return of(year , month , day , hour , minute , second , nanos);
    }
    public MyLocalDateTime minusYear(int year){
        int day    = this.day;
        int month  = this.month;
        int hour   = this.hour;
        int minute = this.minute;
        int second  = this.second;
        int nanos = this.nanos;

        year = this.year - year;
        return of(year , month , day , hour , minute , second , nanos);
    }
    public MyLocalDateTime minusMonth(int month){
        int day    = this.day;
        int year  = this.year;
        int hour   = this.hour;
        int minute = this.minute;
        int second  = this.second;
        int nanos = this.nanos;
        int count = month;
        month = this.month;
        do{
            if(count>=month){
                count-=month;
                month = 12;
                year--;
            }
            else{
                month-=count;
                count=0;
            }
        }while(count!=0);
        return of(year , month , day , hour , minute , second , nanos);
    }
    public MyLocalDateTime minusDays(int day){
        int year = this.year;
        int month = this.month;

        int count = day;
        day = this.day;
        do{
            switch (month) {
                case 1:
                    if (count > day) {
                        count -= day;
                        month = 12;
                        year--;
                        day=31;
                    }
                    else {
                        day-=count;
                        count=0;
                        if(day==0){
                            day = 31 ;
                            month = 12;
                            year--;
                        }
                    }
                    break;
                case 3:
                    if (count > day) {
                        count -= day;
                        month--;
                        if(year%4==0){
                            day=29;
                        }
                        else{
                            day=28;
                        }
                    }
                    else {
                        day-=count;
                        count=0;
                        if(day==0){
                            month --;
                            if(year%4==0){
                                day=29;
                            }
                            else{
                                day=28;
                            }
                        }
                    }
                    break;
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    //System.out.println("运行到了这里"+count);
                    if (count > day) {
                        // System.out.println("运行到了这里"+day);
                        count -= day;
                        // System.out.println("运行到了这里"+count);
                        month--;
                        day=30;
                    }
                    else {
                        // System.out.println("运行到了这里"+count);
                        day-=count;
                        count=0;
                        if(day==0){
                            day = 30 ;
                            month --;
                        }
                    }
                    break;
                case 2:
                case 4:
                case 11:
                case 9:
                case 6:
                    if (count > day) {
                        count -= day;
                        month--;
                        day=31;
                    }
                    else {
                        day-=count;
                        count=0;
                        if(day==0){
                            day = 31 ;
                            month--;
                        }
                    }
                    break;
                default:System.out.println("xxx");
            }
            //System.out.println("运行到了这里"+count);
        }while(count!=0);
        return of(year , month , day , this.hour , this.minute , this.second , this.nanos);

    }
    public MyLocalDateTime minusHour(int hour){
        int day   = this.day;
        int year  = this.year;
        int month = this.month;
        int minute= this.minute;
        int second= this.second;
        int nanos = this.nanos;
        int count1 = hour;
        int count;
        if(count1>=24){
            count = count1/24;
            do{
                switch (month) {
                    case 1:
                        if (count > day) {
                            count -= day;
                            month = 12;
                            year--;
                            day=31;
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                day = 31 ;
                                month = 12;
                                year--;
                            }
                        }
                        break;
                    case 3:
                        if (count > day) {
                            count -= day;
                            month--;
                            if(year%4==0){
                                day=29;
                            }
                            else{
                                day=28;
                            }
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                month --;
                                if(year%4==0){
                                    day=29;
                                }
                                else{
                                    day=28;
                                }
                            }
                        }
                        break;
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:
                        //System.out.println("运行到了这里"+count);
                        if (count > day) {
                            // System.out.println("运行到了这里"+day);
                            count -= day;
                            // System.out.println("运行到了这里"+count);
                            month--;
                            day=30;
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                day = 30 ;
                                month --;
                            }
                        }
                        break;
                    case 2:
                    case 4:
                    case 11:
                    case 9:
                    case 6:
                        if (count > day) {
                            count -= day;
                            month--;
                            day=31;
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                day = 31 ;
                                month--;
                            }
                        }
                        break;
                    default:System.out.println("xxx");
                }
                //System.out.println("运行到了这里"+count);
            }while(count!=0);
        }
        count1%=24;
        hour = this.hour;
        int mount = count1*60*60;
        while(mount>=3600){
            if(hour==0){
                mount-=3600;
                hour=23;
                day--;

            }
            else {
                mount-=3600;
                hour--;
            }

        }
        while(mount>=60){
            if(minute==0){
                mount-=60;
                minute = 59 ;
                if(hour==0){
                    hour=23;
                    day--;
                }
                else  {
                    hour--;
                }
            }
            else {
                mount-=60;
                minute--;
            }

        }
        while(mount!=0){
            if(second==0){
                mount--;
                second = 59;
                minute--;
            }
            else{
                mount--;
                second--;
            }
        }





        return of(year , month , day , hour , minute , second , nanos);
    }
    public MyLocalDateTime minusMinute(int minute){
        int day   = this.day;
        int year  = this.year;
        int month = this.month;
        int hour  = this.hour;
        int second= this.second;
        int nanos = this.nanos;

        int index = minute;
        if(index>=1440){
            int count = index/1440;
            do{
                switch (month) {
                    case 1:
                        if (count > day) {
                            count -= day;
                            month = 12;
                            year--;
                            day=31;
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                day = 31 ;
                                month = 12;
                                year--;
                            }
                        }
                        break;
                    case 3:
                        if (count > day) {
                            count -= day;
                            month--;
                            if(year%4==0){
                                day=29;
                            }
                            else{
                                day=28;
                            }
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                month --;
                                if(year%4==0){
                                    day=29;
                                }
                                else{
                                    day=28;
                                }
                            }
                        }
                        break;
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:
                        //System.out.println("运行到了这里"+count);
                        if (count > day) {
                            // System.out.println("运行到了这里"+day);
                            count -= day;
                            // System.out.println("运行到了这里"+count);
                            month--;
                            day=30;
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                day = 30 ;
                                month --;
                            }
                        }
                        break;
                    case 2:
                    case 4:
                    case 11:
                    case 9:
                    case 6:
                        if (count > day) {
                            count -= day;
                            month--;
                            day=31;
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                day = 31 ;
                                month--;
                            }
                        }
                        break;
                    default:System.out.println("xxx");
                }
                //System.out.println("运行到了这里"+count);
            }while(count!=0);
        }
        int mount = (index%1440)*60;
        minute = this.minute;
        while(mount>=3600){
            if(hour==0){
                mount-=3600;
                hour=23;
                day--;

            }
            else {
                mount-=3600;
                hour--;
            }

        }
        while(mount>=60){
            if(minute==0){
                mount-=60;
                minute = 59 ;
                if(hour==0){
                    hour=23;
                    day--;
                }
                else  {
                    hour--;
                }
            }
            else {
                mount-=60;
                minute--;
            }

        }
        while(mount!=0){
            if(second==0){
                mount--;
                second = 59;
                minute--;
            }
            else{
                mount--;
                second--;
            }
        }
        return of(year , month , day , hour , minute , second , nanos);
    }
    public MyLocalDateTime minusSecond(int second){
        int day   = this.day;
        int year  = this.year;
        int month = this.month;
        int hour  = this.hour;
        int minute= this.minute;
        int nanos = this.nanos;

        int index = second;
        if(index>=86400){
            int count = index/86400;
            do{
                switch (month) {
                    case 1:
                        if (count > day) {
                            count -= day;
                            month = 12;
                            year--;
                            day=31;
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                day = 31 ;
                                month = 12;
                                year--;
                            }
                        }
                        break;
                    case 3:
                        if (count > day) {
                            count -= day;
                            month--;
                            if(year%4==0){
                                day=29;
                            }
                            else{
                                day=28;
                            }
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                month --;
                                if(year%4==0){
                                    day=29;
                                }
                                else{
                                    day=28;
                                }
                            }
                        }
                        break;
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:
                        //System.out.println("运行到了这里"+count);
                        if (count > day) {
                            // System.out.println("运行到了这里"+day);
                            count -= day;
                            // System.out.println("运行到了这里"+count);
                            month--;
                            day=30;
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                day = 30 ;
                                month --;
                            }
                        }
                        break;
                    case 2:
                    case 4:
                    case 11:
                    case 9:
                    case 6:
                        if (count > day) {
                            count -= day;
                            month--;
                            day=31;
                        }
                        else {
                            day-=count;
                            count=0;
                            if(day==0){
                                day = 31 ;
                                month--;
                            }
                        }
                        break;
                    default:System.out.println("xxx");
                }
                //System.out.println("运行到了这里"+count);
            }while(count!=0);
        }
        int mount = index%86400;
        second = this.second;
        while(mount>=3600){
            if(hour==0){
                mount-=3600;
                hour=23;
                day--;

            }
            else {
                mount-=3600;
                hour--;
            }

        }
        while(mount>=60){
            if(minute==0){
                mount-=60;
                minute = 59 ;
                if(hour==0){
                    hour=23;
                    day--;
                }
                else  {
                    hour--;
                }
            }
            else {
                mount-=60;
                minute--;
            }

        }
        while(mount!=0){
            if(second==0){
                mount--;
                second = 59;
                minute--;
            }
            else{
                mount--;
                second--;
            }
        }
        return of(year , month , day , hour , minute , second , nanos);


    }


    //public MyLocalDateTime with(){}
    public MyLocalDateTime withYear(int year){
        return of(year,this.month,this.day,this.hour,this.minute,this.second,this.nanos);
    }
    public MyLocalDateTime withMonth(int month){
        return of(this.year,month,this.day,this.hour,this.minute,this.second,this.nanos);
    }
    public MyLocalDateTime withDay(int day){
        return of(this.year,this.month,day,this.hour,this.minute,this.second,this.nanos);
    }
    public MyLocalDateTime withHour(int hour){
        return of(this.year,this.month,this.day,hour,this.minute,this.second,this.nanos);
    }
    public MyLocalDateTime withMinute(int minute){
        return of(this.year,this.month,this.day,this.hour,minute,this.second,this.nanos);
    }
    public MyLocalDateTime withSecond(int second){
        return of(this.year,this.month,this.day,this.hour,this.minute,second,this.nanos);
    }
    public MyLocalDateTime withNanos(int nanos){
        return of(this.year,this.month,this.day,this.hour,this.minute,this.second,nanos);
    }



    /*private long getSecond(){
        if(this.year < 1970){
            return  0 ;
        }
        else{

        }
    }
    public Date toDate(){

        return new Date(getSecond());
    }

     */

}
